//
//  OCBaseService.h
//  OCDemo
//
//  Created by 朱慕之 on 2021/12/28.
//

#import <Foundation/Foundation.h>
#import "NetWorkRequest.h"

#define PL_ERROR_INFO_KEY   @"errorInfo"
#define PL_ERROR_CODE       @"errorCode"


NS_ASSUME_NONNULL_BEGIN

@interface OCBaseService : NSObject

/**
 *  单例
 */
+ (instancetype)share;

/**
 *  判断网络是否连接
 *
 *  @return YES or NO
 */
+ (BOOL)isConnectNetwork;

/**
 *  根据错误code，得到对应的错误描述信息字符串
 *
 *  @param errorCode 错误code
 *
 *  @return 错误描述信息字符串
 */
+ (NSString *)errorWithCode:(NSInteger)errorCode;

/**
 *  请求数据成功的处理 errorCode、code为0
 *
 *  @param dictionary   请求回来的数据  errorCode、code为0
 *  @param requestInfoModel     XFSRequestInfoModel
 *  @param sucBlock  如果一切正常则会执行该block
 *  @param failBlock 出现其它错误时执行(例如:请求虽然成功,但出现必填参数为空)
 */
- (void)handleRequestSuccess:(NSDictionary *)dictionary
                requestModel:(RequestInfoModel *)requestInfoModel
                    sucBlock:(NetworkRequestSuccessBlock)sucBlock
                   failBlock:(NetworkRequestFailureBlock)failBlock;

/**
 *  请求数据成功的处理  errorCode、code为1
 *
 *  @param dictionary   请求回来的数据  errorCode、code为1
 *  @param requestInfoModel     XFSRequestInfoModel
 *  @param sucBlock  如果一切正常则会执行该block
 *  @param failBlock 出现其它错误时执行(例如:请求虽然成功,但出现必填参数为空)
 */
- (void)handleSpecialRequestSuccess:(NSDictionary *)dictionary
                       requestModel:(RequestInfoModel *)requestInfoModel
                           sucBlock:(NetworkRequestSuccessBlock)sucBlock
                          failBlock:(NetworkRequestFailureBlock)failBlock;

/**
 *  请求数据失败后的处理
 *
 *  @param error     请求失败后返回DDError对象
 *  @param requestInfoModel      XFSRequestInfoModel
 */
- (void)handleRequestFailed:(NSError *)error
               requestModel:(RequestInfoModel *)requestInfoModel
                  failBlock:(NetworkRequestFailureBlock)failBlock;




/**
 *  SRM采购单相关请求数据成功的处理 只取code为0 （SRM强更后，兼容几个版本后可删除）
 *  使用接口：
 *  cart/findShoppingCartCount
 *  cart/deleteShoppingCartList
 *  cart/updateCartCount
 *  cart/addShoppingCartReturnSku
 *
 *  @param dictionary   请求回来的数据  errorCode、code为0
 *  @param requestInfoModel     XFSRequestInfoModel
 *  @param sucBlock  如果一切正常则会执行该block
 *  @param failBlock 出现其它错误时执行(例如:请求虽然成功,但出现必填参数为空)
 */
- (void)handleShopCartRequestSuccess:(NSDictionary *)dictionary
                        requestModel:(RequestInfoModel *)requestInfoModel
                            sucBlock:(NetworkRequestSuccessBlock)sucBlock
                           failBlock:(NetworkRequestFailureBlock)failBlock;



@end

NS_ASSUME_NONNULL_END
